package com.web.farme.pojo;

import com.web.farme.base.BaseErrorInfo;
import lombok.Data;

/**
 * @Classname BizException
 * @Description TODO
 * @Date 2021/4/18 上午8:36
 * @Created by sakura
 */
@Data
public class BizException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    protected String errorCode;
    /**
     * 错误信息
     */
    protected String errorMsg;


    public BizException() {
        super();
    }

    public BizException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BizException(BaseErrorInfo baseErrorInfo, Throwable throwable) {
        super(baseErrorInfo.getResultCode(), throwable);
        this.errorMsg = baseErrorInfo.getResultMsg();
        this.errorCode = baseErrorInfo.getResultCode();
    }

    public BizException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(String errorMsg, String errorCode, Throwable throwable) {
        super(errorCode, throwable);
        this.errorMsg = errorMsg;
        this.errorCode = errorCode;
    }

    /**
     * Constructor with message format
     *
     */
    public BizException(String msgFormat, Object... args) {
        super(String.format(msgFormat, args));
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }
}
